package com.wh.custom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wh.custom.pojo.CustomCustomersource;
import com.wh.custom.dao.CustomSourceMapper;
import com.wh.custom.service.ICustomCustomersourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wh.custom.dto.CustomCustomersourceQueryDto;

/**
 * 业务实现类
 */
@Service
public class CustomCustomersourceServiceImpl extends ServiceImpl<CustomSourceMapper, CustomCustomersource> implements ICustomCustomersourceService {

    @Autowired
    private CustomSourceMapper customSourceMapper;

    @Override
    public IPage<CustomCustomersource> findByPage(CustomCustomersourceQueryDto customCustomersourceQueryDto){
        //1.创建查询条件
        QueryWrapper<CustomCustomersource> qw = new QueryWrapper<>();
        qw.like("customer_source",customCustomersourceQueryDto.getKeyword());
        //qw.or();
        //qw.like("xxx",customCustomersourceQueryDto.getXxx());
        //2.组件分页数据
        IPage<CustomCustomersource> page = new Page<>(customCustomersourceQueryDto.getCurrentPage(), customCustomersourceQueryDto.getPageSize());
        page.setRecords(customSourceMapper.findByPage(page,qw));
        page.setTotal(customSourceMapper.selectCount(qw));
        //3.返回
        return page;
    }
}
